package com.one.square.user.interfaces.service.fallback;

import com.one.square.core.domain.LoginAppUser;
import com.one.square.core.domain.Result;
import com.one.square.user.interfaces.service.service.SysUserInterface;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;

/**
 * @author cwm
 * @Description
 * @date 2021/10/21 下午1:18
 * @Version 1.0
 */
@Slf4j
public class SysUserInterfaceFallBack implements FallbackFactory<SysUserInterface> {
    @Override
    public SysUserInterface create(Throwable throwable) {
        return new SysUserInterface() {
            @Override
            public Result<LoginAppUser> findByUsername(String username) {
                log.error("通过用户名查询用户异常:{}", username, throwable);
                return Result.failed("通过用户名查询用户异常");
            }

            @Override
            public Result<LoginAppUser> findByMobile(String mobile) {
                log.error("通过手机号码查询用户异常:{}", mobile, throwable);
                return Result.failed("通过手机号码查询用户异常");
            }
        };
    }
}
